#include <base\box3f.h>

box3f::box3f(vec3f &corner,  float x, float y, float z) {
	setBox(corner,x,y,z);
}

box3f::box3f(void) {

	corner.x = 0; corner.y = 0; corner.z = 0;

	x = 1.0f;
	y = 1.0f;
	z = 1.0f;
	
}

box3f::~box3f() {

}

void 
box3f::setBox(vec3f &corner_, float x_, float y_, float z_) {

	this->corner = corner_;

	if (x_ < 0.0) {
		x_ = -x_;
		corner.x -= x_;
	}

	if (y_ < 0.0) {
		y_ = -y_;
		corner.y -= y_;
	}

	if (z_ < 0.0) {
		z_ = -z_;
		corner.z -= z_;
	}
	
  x = x_;
	y = y_;
	z = z_;

}

vec3f 
box3f::getVertexP(vec3f &normal) {

	vec3f res = corner;

	if (normal.x > 0) res.x += x;
	if (normal.y > 0) res.y += y;
	if (normal.z > 0)	res.z += z;

	return(res);
}

vec3f 
box3f::getVertexN(vec3f &normal) {

	vec3f res = corner;

	if (normal.x < 0) res.x += x;
	if (normal.y < 0)	res.y += y;
	if (normal.z < 0)	res.z += z;

	return(res);
}

	

